package com.audi.handler;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import com.audi.BaseActivity;
import com.audi.dto.MemberItem;
import com.audi.message.ActionMessage;
import com.audi.utils.ProgressDialogUtil;

public class MemberHandlerAction {
	private Activity mActivity;
	private BaseActivity mBaseActivity;
	private ArrayList<MemberItem> mListMember;
	private ProgressDialogUtil mProgressDialog;
	public MemberHandlerAction(Activity activity) {
		super();
		this.mListMember = new ArrayList<MemberItem>();
		this.mActivity = activity;
		this.mBaseActivity =(BaseActivity) activity;
		mProgressDialog = new ProgressDialogUtil(mActivity);
		
	}
	@SuppressLint("HandlerLeak")
	public Handler addMemberFinishHandler = new Handler() {

		public void handleMessage(final Message msg) {
			mActivity.runOnUiThread(new Runnable() {
				public void run() {
					try {
						if (msg.arg1 != -1) {
							int de = msg.getData().getInt(
									String.valueOf(ActionMessage.addMember));
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			});
		}
	};
	@SuppressLint("HandlerLeak")
	public Handler loadListMemberHandler = new Handler() {

		public void handleMessage(final Message msg) {
			mActivity.runOnUiThread(new Runnable() {
				public void run() {
					try {
						if (msg.arg1 != -1) {
							@SuppressWarnings("unchecked")
							ArrayList<MemberItem> result = (ArrayList<MemberItem>) msg
									.getData()
									.getSerializable(
											String.valueOf(ActionMessage.getListMember));
							
							mListMember = result;
							Log.e("-------------UserName---------", +mListMember.size()+"");
							
							mProgressDialog.DestroyProgressDialog();
						}
					} catch (Exception e) {
					}
				}
			});
		}
	};
	public ArrayList<MemberItem> getAllMember()
	{
		ArrayList<MemberItem> listmember =new ArrayList<MemberItem>();
		if(mListMember != null)
		{
			listmember =mListMember;
			return listmember;
		}
		return null;
		
	}
}
